Contents Screen
TAdrockMessageDialog

Methods 	Installation

Unit

AdDialog

Description

The TAdrockMessageDialog is a direct replacement for the standard Delphi MessageDlg and ShowMessage functions.

The TAdrockMessageDialog supports settings a default dialog button, You can specify which button is the default button when you call the function.  The standard Delphi function MessageDlg does not support a default button. If you wanted a dialog box to say "Do you really want to format the hard disk?" with the standard delphi MessageDialog routine YES is the default button, but the TAdrockMessageDialog you can choose the default button for the Dialog, No or Cancel could be more appropriate in this case.

You can specify that the dialog automatically accepts the default button if the user does not interact with the dialog. If the user does move the input focus, or moves the mouse the dialog resets its inactivity counter.

You can play a wave file or any of the standard windows predefined sounds with a special dialog function.

When you use a standard Delphi MessageDlg and you have changed the cursor say to crHourglass, and you need to popup a message box, normally you would have to code the cursor back to a standard cursor, and then after the end user closed the dialog, you would have to code the cursor back to an hourglass, no so with the TAdrockMessageDialog. The cursor style is saved before opening the message box, and then restored automatically once the dialog is closed.

The mouse cursor can be positioned over the default button, so the user only has to click the mouse for the default button. (This is used with another component that we have written that allows you to position the Cursor on a specific control when the form opens, without requiring any coding).

Simple easy to use dialogs, InformationBox, TimedInformationBox, QueryBox, TimedQueryBox, WarningBox, TimedWarningBox, ErrorBox, TimedErrorBox, and the base function MessageDialog which does all the work for the functions above.

You can have dialogs that can contain 16000 bytes of text instead of the default 255 characters. The 16000 character limit can be modified if you purchase the source code with just 1 line of code to modify.

You now have access to the fonts for the buttons and for the dialog text. You can modify the attributes of the font, size, color, style.

The buttons default to opening at a specific height and size, if you change the buttons font, the text might not fit into the button anymore, you can however modify the default height and width of the buttons.

You can now change the dialogs caption for each style of dialog. The change can be permanent or just for the next dialog to be shown.

The dialog normally just opens in the center of the screen, or at a position you specify with an X,Y. You can now have the dialog open in the center of your application instead of the center of the screen. This also can be set up permanently or just the next dialog that opens.

Using these functions instead of the Standard Delphi functions enables you to make much more user friendly dialogs for your end users. And it also will possibility cut down on the amount of programming that is involved.


Methods

InformationBox	Display a Simple Information Box with an OK Button

QueryBox	Display a Simple Yes\No Query, with Yes and No Buttons.

WarningBox	Display a Warning Box with an OK Button

ErrorBox	Display a Error Box with an OK Button

TimedInformationBox	Display a simple information box with a timer.

TimedQueryBox	Display a simple yes/no box with a timer.

TimedWarningBox	Display a Warning Box with a timer.

TimedErrorBox	Display a Error Box with a timer.

MessageDialogWave	Same as above but allows specific wave files to be played.

MessageDialog	This routine does all the work for the above routines, and more.

BuildTAdrockMessageDialogLine	You call as many of these as needed to build your large text dialog.

BuildTAdrockMessageDialogShow 	This routine shows your large text dialog.

ModifyTAdrockMessageDialogPopupPosition;	Modify the dialogs opening position.

ModifyTAdrockMessageDialogOpeningPercentage;	Modify the dialogs opening width.

ModifyTAdrockMessageDialogCaption;	Modify the dialogs captions.

ModifyTAdrockMessageDialogButtonCaption;	Modify the dialogs button captions.

Variables you can modify before calling a dialog.

TAdrockMessageDialogFont  : TFont;	Dialog Text Font.

TAdrockMessageDialogButtonFont : TFont;	Dialog Button Font.

TAdrockMessageDialogBtnSize: Tpoint	Dialog Button Size, as a TPoint structure.


ModifyTAdrockMessageDialogPopupPosition

Applies to

TAdrockMessageDialog

Declaration

Procedure ModifyTAdrockMessageDialogPopupPosition(Default : Boolean; Style : Integer);

Description

This procedure will allow you to change the opening position of the dialog. The opening position can be set to AdrockMessageDialogCenterToApplication, or AdrockMessageDialogCenterToScreen.

If Default =FALSE then the position is only changed for the next dialog that gets opened. If Default=TRUE then the dialog position is modified for all dialogs in the future.

AdrockMessageDialogCenterToScreen 	- Open Dialog Centered To The Screen

AdrockMessageDialogCenterToApplication	- Open Dialog Centered To The Application

Example

ModifyTAdrockMessageDialogPopupPosition(FALSE, AdrockMessageDialogCenterToApplication);

Set the dialog opening position for the next dialog to center in the application, not the screen.


ModifyTAdrockMessageDialogOpeningPercentage

Applies to

TAdrockMessageDialog

Declaration

Procedure ModifyTAdrockMessageDialogOpeningPercentage(Default : Boolean; Percentage : Integer);

Description

This procedure will allow you to change the dialogs width. By default the width if set to 65% of the screen width.

If Default =FALSE then the dialog width is only changed for the next dialog that gets opened. If Default=TRUE then the dialog width is modified for all dialogs in the future.

Example

ModifyTAdrockMessageDialogOpeningPercentage(TRUE, 45);

Set the dialog opening width to 45%, all dialogs in the future will open at 45%.


ModifyTAdrockMessageDialogCaption

Applies to

TAdrockMessageDialog

Declaration

Procedure ModifyTAdrockMessageDialogCaption(Default : Boolean; DialogStyle : TMsgDlgType; CaptionStr : String);

Description

This procedure will allow you to change the caption for a specific type of dialog.

If Default =FALSE then the dialog caption is only changed for the next dialog that gets opened with that specific type. If Default=TRUE then the dialog caption is modified for all dialogs in the future of that specific type.

DialogStyle refers to which dialog , we want to change the caption for. mtInformation, mtConfirmation, mtWarning, mtError.

CaptionStr is the new caption for the dialog.

Example

ModifyTAdrockMessageDialogCaption(TRUE, mtInformation, My New mtInfromation Caption);

Change the Caption for the Information dialog to My New myInformation Caption, all dialogs that get opened in the future which are mtInformation dialogs will have this caption.


ModifyTAdrockMessageDialogButtonCaption

Applies to

TAdrockMessageDialog

Declaration

Procedure ModifyTAdrockMessageDialogButtonCaption(Default : Boolean; Button : TMsgDlgBtn; CaptionStr : String);

Description

This procedure will allow you to change the caption for a specific type of dialog.

If Default =FALSE then the button caption is only changed for the next dialog that gets opened. If Default=TRUE then the button caption is modified for all dialogs in the future.

Button refers to which button you want to modify, mbOk, mbYes, mbNo, etc.

CaptionStr is the new caption for the specific button.

Example

ModifyTAdrockMessageDialogButtonCaption(TRUE, mbYes, Backup);

Rename the YES button to Backup.


InformationBox

Applies to

TAdrockMessageDialog

Declaration

Procedure InformationBox(Text : String);

Description

This will display an information box similar to the ShowMessage routine, but with an Information Icon.

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

begin

   InformationBox('This is a test of the information box');

end;

See Also : TimedInformationBox


QueryBox

Applies to

TAdrockMessageDialog

Declaration

Function QueryBox(Text : String; DefaultButton : TMsgDlgBtn) : Word;

Description

This will display a QueryBox that asks a simple Yes/No question

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

Var

 Result : Integer;

begin

   Result := QueryBox('Do you really want to format the hard disk? ', mbNo);

   if (Result = mrYes) then

     InformationBox(Format the hard disk)

  else { Result = mrNo }

    InformationBox(Good Idea)

end;

See Also:: TimedQueryBox


WarningBox

Applies to

TAdrockMessageDialog

Declaration

Procedure WarningBox(Text : String);

Description

This will display a warning box with an OK button.

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

begin

   WarningBox (Unable to delete file CHRIS.TEXT ');

end;

See Also:: TimedWarningBox


ErrorBox

Applies to

TAdrockMessageDialog

Declaration

Procedure ErrorBox(Text : String);

Description

This will display a Error Box with an OK button.

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

begin

   ErrorBox (Unable to delete file CHRIS.TEXT ');

end;

See Also: TimedErrorBox


TimedInformationBox

Applies to

TAdrockMessageDialog

Declaration

Procedure TimedInformationBox(Text : String; TimeInSecs : Integer);

Description

This will display an information box similar to the ShowMessage routine, but with an Information Icon, and it will only be visible for the number of seconds specified or until the button is pressed.

 Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

begin

   { Display the information dialog, a maximum of 5 seconds }

   TimedInformationBox('This is a test of the information box',5);

end;

See Also : InformationBox


TimedQueryBox

Applies to

TAdrockMessageDialog

Declaration

Function TimedQueryBox(Text : String; DefaultButton : TMsgDlgBtn; TimeInSecs : Integer ) : Word;

Description

This will display a QueryBox that asks a simple Yes/No question

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

Var

 Result : Integer;

begin

   { No is the default button, and only wait for 5 seconds }

   Result := TimedQueryBox('Do you really want to format the hard disk? ', mbNo,5);

   if (Result = mrYes) then

     InformationBox(Format the hard disk)

  else { Result = mrNo }

    InformationBox(Good Idea)

end;

See Also: QueryBox


TimedWarningBox

Applies to

TAdrockMessageDialog

Declaration

Procedure TimedWarningBox(Text : String; TimeInSecs : Integer);

Description

This will display a warning box with an OK button and it will only be visible for the number of seconds specified or until the button is pressed.

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

begin

   { Display the warning dialog, a maximum of 5 seconds }

   TimedWarningBox (Unable to delete file CHRIS.TEXT ',5);

end;

See Also: WarningBox


TimedErrorBox

Applies to

TAdrockMessageDialog

Declaration

Procedure TimedErrorBox(Text : String; TimeInSecs : Integer);

Description

This will display a Error Box with an OK button, and it will only be visible for the number of seconds specified or until the button is pressed.

Example

Uses AdDialog;

procedure TForm2.Button1Click(Sender: TObject);

begin

   { Display the error dialog, a maximum of 5 seconds }

   TimedErrorBox (Unable to delete file CHRIS.TEXT ',5);

end;

See Also: ErrorBox


MessageBox

Applies to

TAdrockMessageDialog

Declaration

Procedure MessageBox(Const Msg : String; AType: TMsgDlgType; AButtons: TMsgDlgButtons;                                                                                                                         DefaultButton : TMsgDlgBtn; HelpID : Integer);

Description

This is a direct replacement for the MessageDlg function in delphi with one additional parameter to specify the default button.

Example

  MessageBox(Are you sure you want to format, mtConfirmation, [mbYes, mbNo], mbOK,  0);


MessageDialog

Applies to

TAdrockMessageDialog

Declaration

function MessageDialog(const Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons;

         DefaultButton : TMsgDlgBtn; Beep : Integer; Timer : Integer; HelpCtx: Longint): Word;

Description

With this method you can create any sort of dialog that you need to, it is basically very similar to the standard MessageDlg.

The InformationBox, QueryBox, WarningBox, and ErrorBox, and the TimedXXXX routines all call this method to do their work.

You can specify the Default button, the sound to play, how long to wait, and the Help ID.

DefaultButton	MbYes, MbNo, MbOk, etc….

Timer	0=Disable, 1=1 Second, 2=2 Seconds etc…

Beep	MB_ICONASTERISK

Plays the sound identified by the SystemAsterisk entry in the [sounds] section of WIN.INI.

MB_ICONEXCLAMATION

Plays the sound identified by the SystemExclamation entry in the [sounds] section of WIN.INI.

MB_ICONHAND

Plays the sound identified by the SystemHand entry in the [sounds] section of WIN.INI.

MB_ICONQUESTION

Plays the sound identified by the SystemQuestion entry in the [sounds] section of WIN.INI.

MB_OK

Plays the sound identified by the SystemDefault entry in the [sounds] section of WIN.INI.


BuildTAdrockMessageDialogLine

Applies to

TAdrockMessageDialog

Declaration

Procedure BuildTAdrockMessageDialogLine(Line : String);

Description

This method allows you to add a line of text to the special large dialog. This dialog is shown using the function BuildTAdrockMessageDialogShow

The lines are always joined together so that the dialog text is shown nicely. You can force a new line with the Chr(13) or #13.

Begin

 BuildTAdrockMessageDialogLine(This is line #1, of my dialog, with lots of text in it+#13);

 BuildTAdrockMessageDialogLine(This is line #2, of my dialog, with lots of text in it+#13);

 BuildTAdrockMessageDialogLine(This is line #3, of my dialog, with lots of text in it+#13);

 BuildTAdrockMessageDialogLine(This is line #4, of my dialog, with lots of text in it+#13) ;

 BuildTAdrockMessageDialogLine(This is line #5, of my dialog, with lots of text in it+#13) ;

 BuildTAdrockMessageDialogShow(This is my caption, mtInformation, [mbYes,mbNo],mbNo,-1,0,0);

end;


BuildTAdrockMessageDialogShow

Applies to

TAdrockMessageDialog

Declaration

function  BuildTAdrockMessageDialogShow (Caption : String; AType : TMsgDlgType; AButtons : TMsgDlgButtons;  DefaultButton : TMsgDlgBtn; PlaySound : Integer; TimerWait : Integer; HelpCtx: Longint) : Word;

Description

This method opens the dialog that you have created with the BuildTAdrockMessageDialogLine function. By using this function you are able to create large dialogs with up to 16000 bytes of text.

Caption is a string that specifies the Dialog Caption.

Atype is the dialog opening type, mtConfirmation, mtInformation, etc…

Abuttons is the buttons to display in the dialog, eg: mbYes, mbNo, etc, remember to include the []

DefaultButton is the button to make the default button. eg: mbYes, mbNo do not include not []

PlaySound is the sound to hear when the dialog is opened, -1 to disable.

TimerWait is the default button timeout, 0=Disabled, else the number of seconds to wait before timing out and selecting the default button.

HelpCtx is the help context id for the dialog.

Return Value

The button you have clicked, mrYes, mrNo,etc…

Begin

 BuildTAdrockMessageDialogLine(This is line #1, of my dialog, with lots of text in it+#13);

 BuildTAdrockMessageDialogLine(This is line #2, of my dialog, with lots of text in it+#13);

 BuildTAdrockMessageDialogLine(This is line #3, of my dialog, with lots of text in it+#13);

 BuildTAdrockMessageDialogLine(This is line #4, of my dialog, with lots of text in it+#13) ;

 BuildTAdrockMessageDialogLine(This is line #5, of my dialog, with lots of text in it);

 BuildTAdrockMessageDialogShow(This is my caption, mtInformation, [mbYes,mbNo],mbNo,-1,0,0);

End;


MessageDialogWave

Applies to

TAdrockMessageDialog

Declaration

function MessageDialogWave(const Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons;

         DefaultButton : TMsgDlgBtn; WaveFile : String; Timer : Integer; HelpCtx: Longint): Word;

Description

This method is almost identical to the MessageDialog routine. This method allows you to specify a WAVE file to play when the dialog opens.

You can specify the Default button, how long to wait, and the Help ID as well.

DefaultButton	MbYes, MbNo, MbOk, etc….

Timer	0=Disable, 1=1 Second, 2=2 Seconds etc…

WaveFile	Full path to the wave file.

Example

  MessageDialogWave(Are you sure you want to format?, mtConfirmation, [mbYes, mbNo], mbNo, C:\WINDOWS\CONFIRM.WAV:,30,0);


Installation Instructions

To install this component>

•	Getting Started
	•	UNZIP the archive (eg: ADDIALOG.ZIP) to a directory temporally.
	•	Create a directory to hold this component and any others that you will install in the future. (eg: C:\DELPHI\COMPONEN) It is easier to put new components in a separate directory since you can update them easily and if there is a new release of DELPHI it will not effect your component directory.
•	Installation of the HLP and KWF files.
	•	Exit DELPHI is you are running it, as you can not install the KWF file while delphi is running.
	•	Move or copy help file (e.g.: ADDIALOG.HLP) to your Delphi Bin directory (suggest C:\DELPHI\BIN), it only really needs to be somewhere on the path, but the DELPHI bin directory is a good place.
	•	Delphi has a program to add our help index to Delphis help index. What this does is allow you to search for both delphi commands and the commands and properties of the component you want to install. This program is called HELPINST and is found in the DELPHI\HELP sub directory. Copy the keyword file (ADDIALOG.KWF) to the delphi help directory.
	•	Change the current directory to the Delphi Help directory (e.g.: CD C:\DELPHI\HELP)
	•	Run the HELPINST program and load the DELPHI.HDX file from the DELPHI\BIN directory.
	•	Add the .KWF file (e.g.: ADDIALOG.KWF) to the list of indexs.
	•	Save the new index file and then exit the HelpInst program.
•	Installation of the DCU, DCR, HIS and TXT files.
	•	WE DO NOT add the component to the Delphi VCL Library. The Dialog is a class ONLY, not a VCL component.
	•	Copy the DCU, DCR, HIS, and TXT files (or .PAS) to the directory that you made for your components. (e.g.:  C:\DELPHI\COMPONEN)
	•	When you want to use the Dialog Class in your programs you just include  AdDialog in your uses clause. Then  you can use the functions like any other.
•	Other Files.
	•	The ADDIALOG.HIS file contains a history of updates and changes made.
Note:	We hope you have no trouble in using this component in your projects and that you like using it and other Adrock components.  We welcome feedback from you, with you we can make better upgrades and quicker fixes to any problems that you are experiencing. Please contact us at  CompuServe 100353,110 or Internet: DHMCC@IBM.NET.